package com.xyw.code.study20200813.rest;

import com.alibaba.fastjson.JSONObject;
import com.alicp.jetcache.anno.CacheUpdate;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xyw.code.study20200813.cache.UserCache;
import com.xyw.code.study20200813.dao.SysUserMapper;
import com.xyw.code.study20200813.po.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Wrapper;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xuyiwei
 * Date: 2020/8/13
 * Time: 上午10:25
 * Email: 1328312923@qq.com
 * Description: No Description
 **/
@RestController
public class SysUserController {

    @Autowired
    private UserCache userCache;

    @Autowired
    private SysUserMapper sysUserMapper;

    @RequestMapping("select/{id}")
    public String select(@PathVariable(value = "id") Long id){
        SysUser sysUser = userCache.selectById(id);
        return JSONObject.toJSONString(sysUser);
    }

    @RequestMapping("update")
    public String update(){
        SysUser sysUser = sysUserMapper.selectById(4L);
        sysUser.setUsername("第二次该");
        userCache.update(sysUser);
        return JSONObject.toJSONString(sysUser);
    }

    @RequestMapping("delete")
    public String delete(){
        userCache.delete(4L);
        return "";
    }
}
